<extend name="Public/base"/>
<block name="style">
<script type="text/javascript" src="__PUBLIC__/uploadify/jquery.uploadify.min.js"></script>
</block>

<block name="body">
    <div class="am-cf am-u-md-12 header-title">
        <h2>{$title}<if condition="$suggest">（{$suggest|htmlspecialchars}）</if></h2>
    </div>

    <form action="{$savePostUrl}" method="post" class="am-form am-form-horizontal form-horizontal">
    <div class="am-cf am-u-md-12">
        <if condition="!empty($group)">
        <ul class="am-nav am-nav-tabs group_nav">
            <volist name="group" id="vGroup">
                <li class="<if condition="$i eq 1">am-active</if>"><a href="javascript:">{$key}</a></li>
            </volist>
        </ul>
        </if>
        <php>if($group){</php>
        <volist name="group" id="vGroup">
            <div class="am-cf group_list am-margin-top" style="<if condition='$i neq 1'>display: none;</if>">
                <volist name="vGroup" id="field">
                    <include file="Common@Default/Builder/_key"/>
                </volist>
            </div>
        </volist>
        <php>}else{</php>
        <volist name="keyList" id="field">
            <include file="Common@Default/Builder/_key"/>
        </volist>
        <php>}</php>
        <volist name="keyList" id="field">
        <if condition="$field['type'] eq 'hidden'">
        <include file="Common@Default/Builder/_key"/>
        </if>
        </volist>

        <div class="am-cf am-form-group">
            <div class="am-u-sm-10 am-u-sm-offset-2">
            <volist name="buttonList" id="button">
                <button {$button.attr}>{$button.title}</button>  &nbsp;
            </volist>
            </div>
        </div>
    </div>
    </form>

</block>

<block name="script">

    <if condition="$importDatetimePicker">
        <script>
            $('.time').datetimepicker({
                format: 'yyyy-mm-dd hh:ii',
                language: "zh-CN",
                minView: 0,
                autoclose: true
            }).attr('readonly','true');

            $('.time').change(function () {
                var fieldName = $(this).attr('data-field-name');
                var dateString = $(this).val();
                var date = new Date(dateString);
                var timestamp = date.getTime();
                $('[name=' + fieldName + ']').val(Math.floor(timestamp / 1000));
            }).attr('readonly','true');
        </script>
    </if>

    <if condition="$importCheckBox">
        <script>
            $(function () {
                function implode(x, list) {
                    var result = "";
                    for (var i = 0; i < list.length; i++) {
                        if (result == "") {
                            result += list[i];
                        } else {
                            result += ',' + list[i];
                        }
                    }
                    return result;
                }

                $('.oneplus-checkbox').change(function (e) {
                    var fieldName = $(this).attr('data-field-name');
                    var checked = $('.oneplus-checkbox[data-field-name=' + fieldName + ']:checked');
                    var result = [];
                    for (var i = 0; i < checked.length; i++) {
                        var checkbox = $(checked.get(i));
                        result.push(checkbox.attr('value'));
                    }
                    result = implode(',', result);
                    $('.oneplus-checkbox-hidden[data-field-name=' + fieldName + ']').val(result);
                });
            })
        </script>
    </if>

    <script type="text/javascript">
        $(function () {
            $('.group_nav li a').click(function () {
                $('.group_list').hide();
                $('.group_list').eq($(".group_nav li a").index(this)).show();
                $('.group_nav li').removeClass('am-active');
                $(this).parent().addClass('am-active');
            })
        })
        Think.setValue("type", {$info.type|default=0});
        Think.setValue("group", {$info.group|default=0});
        //导航高亮
        highlight_subnav('{:U('Config / index')}');
    </script>
</block>
